package com.ruoyi.module.memberInvestmentMessage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.memberInvestmentMessage.domain.MemberInvestmentMessage;
import com.ruoyi.module.memberInvestmentMessage.service.IMemberInvestmentMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 协会招商留言Controller
 * 
 * @author yqq
 * @date 2024-07-17
 */
@RestController
@RequestMapping("/api/MemberInvestmentMessage")
public class MemberInvestmentMessageController extends BaseController
{
    @Autowired
    private IMemberInvestmentMessageService memberInvestmentMessageService;

    /**
     * 查询协会招商留言列表
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestmentMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberInvestmentMessage memberInvestmentMessage)
    {
        startPage();
        List<MemberInvestmentMessage> list = memberInvestmentMessageService.selectMemberInvestmentMessageList(memberInvestmentMessage);
        return getDataTable(list);
    }

    /**
     * 导出协会招商留言列表
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestmentMessage:export')")
    @Log(title = "协会招商留言", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberInvestmentMessage memberInvestmentMessage)
    {
        List<MemberInvestmentMessage> list = memberInvestmentMessageService.selectMemberInvestmentMessageList(memberInvestmentMessage);
        ExcelUtil<MemberInvestmentMessage> util = new ExcelUtil<MemberInvestmentMessage>(MemberInvestmentMessage.class);
        util.exportExcel(response, list, "协会招商留言数据");
    }

    /**
     * 获取协会招商留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestmentMessage:query')")
    @GetMapping(value = "/{messageId}")
    public AjaxResult getInfo(@PathVariable("messageId") Long messageId)
    {
        return success(memberInvestmentMessageService.selectMemberInvestmentMessageByMessageId(messageId));
    }

    /**
     * 新增协会招商留言
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestmentMessage:add')")
    @Log(title = "协会招商留言", businessType = BusinessType.INSERT)
    @PostMapping("/post")
    public AjaxResult add(@RequestBody MemberInvestmentMessage memberInvestmentMessage)
    {
        return toAjax(memberInvestmentMessageService.insertMemberInvestmentMessage(memberInvestmentMessage));
    }

    /**
     * 修改协会招商留言
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestmentMessage:edit')")
    @Log(title = "协会招商留言", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody MemberInvestmentMessage memberInvestmentMessage)
    {
        return toAjax(memberInvestmentMessageService.updateMemberInvestmentMessage(memberInvestmentMessage));
    }

    /**
     * 删除协会招商留言
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestmentMessage:remove')")
    @Log(title = "协会招商留言", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{messageId}")
    public AjaxResult remove(@PathVariable Long messageId)
    {
        return toAjax(memberInvestmentMessageService.deleteMemberInvestmentMessageByMessageId(messageId));
    }
}
